package com.wg.dome.handle;

import com.wg.dome.ClientPeer;
import com.wg.dome.ErrorHelper;
import com.wg.dome.annotation.Request;
import com.wg.dome.chat.ChatLobby;
import com.wg.dome.operation.ChatRequest;
import com.wg.common.net.OperationRequest;
import com.wg.common.net.OperationResponse;
import com.wg.common.net.SendParameters;
import com.wg.dome.operation.OperationCode;

/**
 * 转发聊天信息
 */
@Request(OperationCode = OperationCode.SEND_CHAT)
public class HandleSendChatRequest extends BaseHandle {

    @Override
    public OperationResponse execute(ClientPeer peer, OperationRequest request, SendParameters sendParameters) {
        ChatRequest chatRequest = new ChatRequest(request);
        if (!chatRequest.isValid()) {
            return ErrorHelper.getInvalidResponse(chatRequest);
        }
        ChatLobby chatLobby = peer.getApplication().getChatLobby();
        chatLobby.onSendChat(request, sendParameters);
        return null;
    }
}
